use std::{ffi::CStr, os::raw::c_char};

#[inline]
pub fn i8_ptr_2_str(i8_ptr: &*const i8) -> &'static str {
    unsafe{ CStr::from_ptr(*i8_ptr) }.to_str().unwrap()
}

#[inline]
pub fn i8_2_str(i8_str: &[i8; 256]) -> &str {
    i8_ptr_2_str(&i8_str.as_ptr())
}

/// Helper function to convert [c_char; SIZE] to string
pub fn i8_2_string(raw_string_array: &[c_char]) -> String {
    let raw_string = unsafe {
        let pointer = raw_string_array.as_ptr();
        CStr::from_ptr(pointer)
    };

    raw_string
        .to_str()
        .expect("Failed to convert vulkan raw string.")
        .to_owned()
}